package tanshiru2.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tanshiru2.entity.FeedBack;
import tanshiru2.service.FeedBackService;
import tanshiru2.util.RespResult;
import tanshiru2.util.ValidationUtils;


@Controller
@RequestMapping("/feedback")
public class FeedBackController extends BaseController {
    @Autowired
    private FeedBackService feedBackService;
    @PostMapping("/save")
    @ResponseBody
    public RespResult save(FeedBack feedBack){

        if (!(ValidationUtils.validateEmail(feedBack.getEmail()))){
            return RespResult.fail("邮箱地址错误");
        }
        feedBackService.save(feedBack);
        return RespResult.success("提交成功");
    }
}
